def readmodel():
    import GlobalParam as GP
    import re
    gp=GP.iparam
    tu=GP.timeunit
    # read generic model
    for i in range(gp.get_npmodel()):
        model_file_name=gp.pmodel1(i).get_filename()
        fp=open(model_file_name+'.def','r')
        while True:
            eatline=fp.readline()
            if not eatline:
                break
            eatline=eatline.strip()
            if len(eatline)==0:
                continue
            if bool(re.match(r"^#",eatline)):
                continue
            reat=re.match(r"^(\w+)\b",eatline)
            try:
                rstr=reat.string[reat.end(1)+1:len(reat.string)]
            except:
                raise Exception
            fields=rstr.split()
            nfields=len(fields)
            # String for name (idstring,length of data)
            gp.pmodel1(i).add_model(reat.group(1).strip(),nfields,0.0)
            model_no=gp.pmodel1(i).get_nmodel()-1
            for j in range(nfields):
                gp.pmodel1(i).set_data(model_no,j,\
                                           GP.total_seconds(tu.TransToTimeDelta(fields[j])))
        fp.close()
